﻿<%@ Page Language="C#" AutoEventWireup="true" Codebehind="SelectMultiDiaBan.aspx.cs" Inherits="CMS.Web.CompDenu.SelectMultiDiaBan" %>
<script language="javascript" type="text/javascript" src="../Common/util.js"></script>
<script language="javascript" type="text/javascript" src="../Common/jquery.js"></script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Chọn địa bàn gửi đơn</title>    
    <style type="text/css">
    .divframe {background-color:white;border:1px solid #35B5CE;font-size:12px;
    height:380px;margin:2px;overflow:auto;padding:1px;width:272px;}
    </style>
</head>
<body style="margin:0px" class="">
    <form id="form1" runat="server">
        
            <table style="border-collapse: collapse"
                cellspacing="0" cellpadding="0" width="100%" border="0">
                <tr>
                    <td class="Text_Main" colspan="2">
                        Chọn địa bàn:</td>
                </tr>
                <tr>
                    <td class="Col_Right" style="width:82%;">
                        <div class="divframe">
                        <asp:TreeView ID="trvDiaBan" runat="server" ShowLines="true" LineImagesFolder="~/Images/" ExpandDepth="0" ShowCheckBoxes="Leaf" />
                        </div>      
                    </td>
                     <td align="center">
                        <input type="button" id="Button1" class="Button" value="&nbsp;Chọn&nbsp;" style="width:60px;" onclick="FindNodeCheked();" /><br /> 
                        <input type="button" id="btnCancel" class="Button" value="Hủy bỏ" style="width:60px;" onclick="window.close();" />                        
                    </td>
                </tr>
                <%--<tr class="Row_Button">
                    <td align="center">
                        <input type="button" id="Button1" class="Button" value="&nbsp;Chọn&nbsp;" onclick="FindNodeCheked();" />   
                        <input type="button" id="btnCancel" class="Button" value="Hủy bỏ" onclick="window.close();" />                        
                    </td>
                </tr>--%>
            </table>              
    </form>
    <script type="text/javascript">         
        function OnTreeClick(mEvent)
        {
            var src = window.event != window.undefined ? window.event.srcElement : mEvent.target;
            var nodeClick = src.tagName.toLowerCase() == "a";            
            if (nodeClick){
                return false;
            }
                 
        }
        function SetDiaBan(diabanId, dbName){
            if(window.opener){
                parentWindow =  window.opener;
            }else{
                parentWindow = window.dialogArguments;
            }
            var txtDiaBan = parentWindow.document.getElementById("<%=ObjId%>");
            var hidId = parentWindow.document.getElementById("<%=HidId%>");    
            hidId.value = diabanId;
            txtDiaBan.value = dbName;   
            window.close();
        }
        function GetNodeValue2(href)
        {
            var nodeValue = "";
            var nodePath = href.substring(href.indexOf(",")+2,href.length-2);
            var nodeValues = nodePath.split("\\");
            if(nodeValues.length > 1)
                nodeValue = nodeValues[nodeValues.length - 1];
            else
                nodeValue = nodeValues[0].substr(1); 
            return nodeValue;
        } 
        function FindNodeCheked(){
            nodeValue = "";
            nodeText = "";
            $("#trvDiaBan input:checkbox:checked").each(function() {
                id = this.id.replace(/CheckBox/gi,'').replace(/trvDiaBann/gi,'trvDiaBant');     
                objChecked = $("#" + id);           
                nodeValue += (nodeValue=="")? GetNodeValue2(objChecked.attr("href")) : ","+ GetNodeValue2(objChecked.attr("href"));
                nodeText += (nodeText=="") ? objChecked.html() : ";"+objChecked.html();
                
            });
            SetDiaBan(nodeValue, nodeText);
        }
    </script>    
</body>
</html>
